﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bussiness;
using System.Data;

namespace EWebsite.Admin.Carriers {
    public partial class Default : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            if (!IsPostBack) {
                _dataBind();
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e) {
            CarrierBuss buss = new CarrierBuss();
            buss.update(txtName.Text, txtInfo.Text, txtWSName.Text, txtWSLink.Text, txtPvdID.Text, txtPwd.Text, txtCreditCardNumber.Text, txtCreditCardHolderName.Text, txtCreditCardSecureNum.Text);

            _dataBind();
        }

        protected void _dataBind() {
            CarrierBuss buss = new CarrierBuss();
            DataTable table = buss.getCarriers();
            if (table.Rows.Count > 0) {
                txtInfo.Text = table.Rows[0]["CarrierInfo"].ToString();
                txtName.Text = table.Rows[0]["CarrierName"].ToString();
                txtPvdID.Text = table.Rows[0]["PvdID"].ToString();
                txtPwd.Text = table.Rows[0]["PvdPwd"].ToString();
                txtWSLink.Text = table.Rows[0]["LinkWS"].ToString();
                txtWSName.Text = table.Rows[0]["WSName"].ToString();
                txtCreditCardNumber.Text = table.Rows[0]["CreditCardNumber"].ToString();
                txtCreditCardHolderName.Text = table.Rows[0]["CardHolderName"].ToString();
                txtCreditCardSecureNum.Text = table.Rows[0]["CardSecureNum"].ToString();
            }
        }
    }
}